package com.gitee.huanminabc.jcommon.base;

import java.util.Collection;
import java.util.Map;

public abstract class Assert {

	public static void isTrue(boolean expression, String message) {
		if (!expression) {
			throw new IllegalArgumentException(message);
		}
	}

	public static void isFalse(boolean expression, String message) {
		if (expression) {
			throw new IllegalArgumentException(message);
		}
	}

	public static void notNull(Object object, String message) {
		if (object == null) {
			throw new NullPointerException(message);
		}
	}


	public static void notEmpty(String str, String message) {
		if (str == null || str.isEmpty()) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void notEmpty(Object[] array, String message) {
		if (array == null || array.length == 0) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void notEmpty(Collection<?> collection, String message) {
		if (collection == null || collection.isEmpty()) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void notEmpty(Map<?, ?> map, String message) {
		if (map == null || map.isEmpty()) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void isNull(Object object, String message) {
		if (object != null) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void isEmpty(String str, String message) {
		if (str != null && !str.isEmpty()) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void isEmpty(Object[] array, String message) {
		if (array != null && array.length > 0) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void isEmpty(Collection<?> collection, String message) {
		if (collection != null && !collection.isEmpty()) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void isEmpty(Map<?, ?> map, String message) {
		if (map != null && !map.isEmpty()) {
			throw new IllegalArgumentException(message);
		}
	}
	public static void isEqual(Object a, Object b, String message) {
		if (a == null && b == null) {
			return;
		}
		if (a == null || !a.equals(b)) {
			throw new IllegalArgumentException(message);
		}
	}

}
